{include file='fcworker/fc_head'}
<style type="text/css">
    .btn-div{
        width: 100%;
        text-align: center;
        margin: 0 auto;
    }
    .btn{
        width: 184px;
        height: 35px;
        background-color: #5c99f7;
        border-radius: 50px;
        border: 0;
        margin-top: 20px;
        color: #fff;
        font-size: 15px;
        font-weight: 400;
    }

    .edittuan{
        position: absolute;
        text-align: center;
        background-color: #fa535b;
        border-radius: 50px;
        width: 75px;
        height: 30px;
        line-height: 30px;
        right: 11px;
        top: 0px;
        color: #fff;
        font-size: 15px;
        font-weight: 400;
    }

    .mybtn-con-min{

        border-radius: 50px;
        margin: 8px;
        color: #fff;
        height: 40px;
        font-size: 15px;
        font-weight: 400;
        border: none;
        display: flex;
        justify-content: center;
        align-items: center;

    }
    .flexasd button ,.flexasd a{
        padding: 0 20px;
        margin: 0;
    }
</style>
<body style="background:#f8f8f8">
<div id="mescroll" class="mescroll">
    <div id="app">
        <div class="setTitle">
            <a href="javascript:history.back(-1)"></a>
            修改订单
        </div>
        <div class="h167"></div>
        {if $record['username']}
        <form id="myform3">
            <div class="setActive">
                <div class="actTit">
                    基本信息:ID.{$record['id']}
                </div>
                <ul>
                    <li>
                        <p class="nametext">{$config['nametext']}{if !$config['isedit']}(不可修改){/if}</p>
                        <input type="text" name="username" confirm-type="next" placeholder="请输入{$config['nametext']}" value="{$record['username']}" {if !$config['isedit']} readonly{/if}>
                    </li>
                    <li>
                        <p class="mobiletext">{$config['mobiletext']}{if !$config['isedit']}(不可修改){/if}</p>
                        <input type="text" name="mobile" confirm-type="next" placeholder="请输入{$config['mobiletext']}" value="{$record['mobile']}" {if !$config['isedit']} readonly{/if}>
                    </li>
                    {if $config['isedit']}
                    {if !empty($config['datetime'])}
                    {if $config['datetimetype']==0 || $config['datetimetype']==1 || $config['datetimetype']==6}
                    <li>
                        <p>{$config['datetime']}</p>
                        <input type="{php echo $config['datetimetype']==0?'text':'number';}"  name="datetime"
                               placeholder-class="input-placeholder" confirm-type="next" value="{$record['datetime']}" placeholder="请输入{$config['datetime']}"
                               {if !$config['isedit']} readonly{/if}>
                    </li>
                    {/if}
                    {if $config['datetimetype']==2 && $config['datetimeoptions']}
                    <li>
                        <p>{$config['datetime']}</p>
                        <select name="datetime"  id="select_datetime" {if !$config['isedit']} disabled{/if}>
                        <option value="" >请选择</option>
                        {loop $config['datetimeoptions']  $key $item}
                        <option value="{$item}" {if $record['datetime'] == $item }selected="selected"{/if} >{$item}</option>
                        {/loop}
                        </select>
                    </li>
                    {/if}
                    {if $config['datetimetype']==3 && $config['datetimeoptions']}
                    <li>
                        <p>{$config['datetime']}</p>
                        <div class="choseBar2">
                            {loop $config['datetimeoptions'] $key $item}
                            <label><input type="radio"  style="height: auto;width: auto;"  {if !$config['isedit']} disabled{/if} name="datetime" value="{$item}" {php echo $record['datetime']==$item?'checked':'';} />{$item}</label>
                            {/loop}
                        </div>
                    </li>
                    {/if}
                    {if $config['datetimetype']==7 || $config['datetimetype']==10}
                    <li>
                        <p>{$config['datetime']}</p>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input" id="date_datetime" {if !$config['isedit']} disabled{/if} placeholder="请选择"  name="datetime" value="{$record['datetime']}">
                        </div>
                    </li>
                    {/if}
                    {/if}
                    {if !empty($config['address'])}
                    {if $config['addresstype']==0 || $config['addresstype']==1 || $config['addresstype']==6}
                    <li>
                        <p>{$config['address']}</p>
                        <input type="{php echo $config['addresstype']==0?'text':'number';}"  name="address"
                               placeholder-class="input-placeholder" confirm-type="next" value="{$record['address']}" placeholder="请输入{$config['address']}"
                               {if !$config['isedit']} readonly{/if}>
                    </li>
                    {/if}
                    {if $config['addresstype']==2 && $config['addressoptions']}
                    <li>
                        <p>{$config['address']}</p>
                        <select name="address"  id="select_address" {if !$config['isedit']} disabled{/if}>
                        <option value="" >请选择</option>
                        {loop $config['addressoptions']  $key $item}
                        <option value="{$item}" {if $record['address'] == $item }selected="selected"{/if} >{$item}</option>
                        {/loop}
                        </select>
                    </li>
                    {/if}
                    {if $config['addresstype']==3 && $config['addressoptions']}
                    <li>
                        <p>{$config['address']}</p>
                        <div class="choseBar2">
                            {loop $config['addressoptions'] $key $item}
                            <label><input type="radio"  style="height: auto;width: auto;"  {if !$config['isedit']} disabled{/if} name="address" value="{$item}" {php echo $record['address']==$item?'checked':'';} />{$item}</label>
                            {/loop}
                        </div>
                    </li>
                    {/if}
                    {if $config['addresstype']==7}
                    <li>
                        <p>{$config['address']}</p>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input" id="date_address" {if !$config['isedit']} disabled{/if} placeholder="请选择"  name="address" value="{$record['address']}">
                        </div>
                    </li>
                    {/if}
                    {/if}

                    {if !empty($config['formtwo'])}
                    {if $config['formtwotype']==0 || $config['formtwotype']==1 || $config['formtwotype']==6}
                    <li>
                        <p>{$config['formtwo']}</p>
                        <input type="{php echo $config['formtwotype']==0?'text':'number';}"  name="formtwo"
                               placeholder-class="input-placeholder" confirm-type="next" value="{$record['formtwo']}" placeholder="请输入{$config['formtwo']}"
                               {if !$config['isedit']} readonly{/if}>
                    </li>
                    {/if}
                    {if $config['formtwotype']==2 && $config['formtwooptions']}
                    <li>
                        <p>{$config['formtwo']}</p>
                        <select name="formtwo"  id="select_formtwo" {if !$config['isedit']} disabled{/if}>
                        <option value="" >请选择</option>
                        {loop $config['formtwooptions']  $key $item}
                        <option value="{$item}" {if $record['formtwo'] == $item }selected="selected"{/if} >{$item}</option>
                        {/loop}
                        </select>
                    </li>
                    {/if}
                    {if $config['formtwotype']==3 && $config['formtwooptions']}
                    <li>
                        <p>{$config['formtwo']}</p>
                        <div class="choseBar2">
                            {loop $config['formtwooptions'] $key $item}
                            <label><input type="radio"  style="height: auto;width: auto;"  {if !$config['isedit']} disabled{/if} name="formtwo" value="{$item}" {php echo $record['formtwo']==$item?'checked':'';} />{$item}</label>
                            {/loop}
                        </div>
                    </li>
                    {/if}
                    {if $config['formtwotype']==7 || $config['formtwotype']==10}
                    <li>
                        <p>{$config['formtwo']}</p>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input" id="date_formtwo" {if !$config['isedit']} disabled{/if} placeholder="请选择"  name="formtwo" value="{$record['formtwo']}">
                        </div>
                    </li>
                    {/if}
                    {/if}
                    {if !empty($config['addinfo'])}
                    {if $config['addinfotype']==0 || $config['addinfotype']==1 || $config['addinfotype']==6}
                    <li>
                        <p>{$config['addinfo']}</p>
                        <input type="{php echo $config['addinfotype']==0?'text':'number';}"  name="addinfo"
                               placeholder-class="input-placeholder" confirm-type="next" value="{$record['addinfo']}" placeholder="请输入{$config['addinfo']}"
                               {if !$config['isedit']} readonly{/if}>
                    </li>
                    {/if}
                    {if $config['addinfotype']==2 && $config['addinfooptions']}
                    <li>
                        <p>{$config['addinfo']}</p>
                        <select name="addinfo"  id="select_addinfo" {if !$config['isedit']} disabled{/if}>
                        <option value="" >请选择</option>
                        {loop $config['addinfooptions']  $key $item}
                        <option value="{$item}" {if $record['addinfo'] == $item }selected="selected"{/if} >{$item}</option>
                        {/loop}
                        </select>
                    </li>
                    {/if}
                    {if $config['addinfotype']==3 && $config['addinfooptions']}
                    <li>
                        <p>{$config['addinfo']}</p>
                        <div class="choseBar2">
                            {loop $config['addinfooptions'] $key $item}
                            <label><input type="radio"  style="height: auto;width: auto;"  {if !$config['isedit']} disabled{/if} name="addinfo" value="{$item}" {php echo $record['addinfo']==$item?'checked':'';} />{$item}</label>
                            {/loop}
                        </div>
                    </li>
                    {/if}
                    {if $config['addinfotype']==7}
                    <li>
                        <p>{$config['addinfo']}</p>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input" id="date_addinfo" {if !$config['isedit']} disabled{/if} placeholder="请选择"  name="addinfo" value="{$record['addinfo']}">
                        </div>
                    </li>
                    {/if}
                    {/if}
                    {if !empty($config['shops'])}
                    {if $config['shopstype']==0 || $config['shopstype']==1 || $config['shopstype']==6}
                    <li>
                        <p>{$config['shops']}</p>
                        <input type="{php echo $config['shopstype']==0?'text':'number';}"  name="shops"
                               placeholder-class="input-placeholder" confirm-type="next" value="{$record['shops']}" placeholder="请输入{$config['shops']}"
                               {if !$config['isedit']} readonly{/if}>
                    </li>
                    {/if}
                    {if $config['shopstype']==2 && $config['shopsoptions']}
                    <li>
                        <p>{$config['shops']}</p>
                        <select name="shops"  id="select_shops" {if !$config['isedit']} disabled{/if}>
                        <option value="" >请选择</option>
                        {loop $config['shopsoptions']  $key $item}
                        <option value="{$item}" {if $record['shops'] == $item }selected="selected"{/if} >{$item}</option>
                        {/loop}
                        </select>
                    </li>
                    {/if}
                    {if $config['shopstype']==3 && $config['shopsoptions']}
                    <li>
                        <p>{$config['shops']}</p>
                        <div class="choseBar2">
                            {loop $config['shopsoptions'] $key $item}
                            <label><input type="radio"  style="height: auto;width: auto;"  {if !$config['isedit']} disabled{/if} name="shops" value="{$item}" {php echo $record['shops']==$item?'checked':'';} />{$item}</label>
                            {/loop}
                        </div>
                    </li>
                    {/if}
                    {if $config['shopstype']==7}
                    <li>
                        <p>{$config['shops']}</p>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input" id="date_shops" {if !$config['isedit']} disabled{/if} placeholder="请选择"  name="shops" value="{$record['shops']}">
                        </div>
                    </li>
                    {/if}
                    {/if}

                    {if $config['shopstype']==4 && $config['shops'] && $config['shopsoptions']}
                    <li>
                        <p>{$config['shops']}</p>
                        <div class="moreChose">
                            {loop $selectedArr $key $item}
                            <input type="checkbox" style="height: auto;width: auto;" {if !$config['isedit']} disabled{/if}  name="formduoxuanvalue"  value="{$item['name']}" {if $item['checked']} checked="checked"{/if}>{$item['name']}
                            {/loop}
                        </div>
                    </li>
                    {/if}

                    <!--                    分类多选-->
                    {if $config['shopstype']==8 && $config['shops'] }
                    <li>
                        <p>{$config['shops']}</p>
                        <div class="shops_category_all">
                            {loop $dx_cate $k $val}
                            <div class="shops_category" style="margin-bottom: 8px;">
                                <div class="shops_category_title">{$val['name']}</div>
                                <div class="shops_category_list" style="display: flex;justify-content: space-around;flex-direction: column;">
                                    {loop $val['list'] $key $item}
                                    <?php  $item_can_show = \app\model\Common::getFormFIveAndLimitBuyCanShowByItemId($baseinfo['config'],$themeid,$item['id']);?>
                                    {if $item['status']==1}
                                        <div class="shops_category_list_item" style="display: flex;align-items: center;height: 30px;line-height: 30px">
                                            <input type="checkbox" style="height: auto;width: auto;" {if !$config['isedit']} disabled{/if}  name="formduoxuanvalue" data-cid="{$val['cid']}" data-sjid="{$val['sj_id']}" data-cmin="{$val['min']}"
                                            data-cmax="{$val['max']}" data-price="{$item['price']}" data-category="{$val['name']}" data-isdefault="{$item['is_default']}" value="{$item['id']}" {if $item['checked']} checked="checked"{/if}>{$item['name']}
                                            {if !$item_can_show && !$item['checked']}(库存不足){/if}
                                        </div>
                                    {/if}
                                    {/loop}
                                </div>
                            </div>
                            {/loop}
                        </div>
                    </li>
                    {/if}
                    {/if}

                    {if $level ==1}
                    <li>
                        <p>所属员工</p>
                        <select id="windex" name="windex" >
                            {loop $wlist $key $item}
                            <option value="{$item['value']}" {if $windex == $key }selected="selected"{/if}>{$item['name']}</option>
                            {/loop}
                        </select>
                    </li>
                    {/if}
                    {if $config['maxcountall']>1 && $config['iseditgroup']==1}
                    <li style="position: relative">
                        <p>所属团【身份:{$record['shenfen']}】</p>
                        <select id="tuanindex" name="tuanindex" style="font-size: .28rem">
                            {loop $tuanlist $key $item}
                            <option value="{$item['value']}" {if $tuanindex == $key }selected="selected"{/if}>{$item['name']}</option>
                            {/loop}
                        </select>
                        <div class="edittuan">修改团</div>
                    </li>
                    {/if}
                </ul>
            <div class="actTit">
                备注信息:
            </div>
            <ul>
            <li>
                <p>客户来源</p>
                <select name="is_member" style="font-size: .28rem">
                    {loop $result['member_from'] $key $item}
                    <option value="{$key}" {if $record['is_member'] == $key }selected="selected"{/if}>{$item}</option>
                    {/loop}
                </select>
            </li>
            <li>
                <p>{php echo $system['is_member_points']==1?'会员积分':'储值卡余额';}</p>
                <input type="text" name="chongzhi" confirm-type="next" value="{$record['chongzhi']}">
            </li>
            <li>
                <p>备注</p>
                <input type="text" id="member_beizhu" name="member_beizhu" confirm-type="next" value="{$record['member_beizhu']}">
            </li>
            <div style="display: flex;justify-content: space-around;align-items: center">
                <p style="color:#666666" onclick="addText('邀约月日上下午到店')">邀约*月*日*午到店⇧</p><p style="color:#666666" onclick="addText('预约月日点拍摄')">预约*月*日*点拍摄⇧</p><p style="color:#666666" onclick="addText('【已转单】')">已转单⇧</p>
            </div>
            <div class="btn-div martop80">
                <button class="btn" id="sub3" type="button">提交</button>
            </div>

                    <div class="h110"></div>

                {if $level ==1 || $config['isedit']}
                    {if $config['maxcountall']>1 && ($record['status']>0 || $record['status']==-2)}
                    <li>
                        <div class="flexasd" style="display: flex;justify-content: space-around;align-items: center">
                            {if $record['type']==9}
                            <button class="mybtn-con-min" type="button" style="background-color: #CC9999;margin-left:15px;margin-right:15px" data-id="{$record['id']}" data-op="uptuanzhang">单买改团长</button>
                            {else}
                            {if $config['groupneednum']>1 && $level == '1'}
                            <button class="mybtn-con-min" type="button" style="background-color: #0099CC;margin-left:10px;margin-right:10px" data-id="{$record['id']}" data-op="newtuan">开新团：原团保留</button>
                            <button class="mybtn-con-min" type="button" style="background-color: #CCCC99;margin-left:10px;margin-right:10px" data-id="{$record['id']}" data-op="newtuan2">开新团：原团移除</button>
                            {/if}
                            {/if}
                        </div>
                    </li>
                    {/if}

                    {if $record['status']>0 && !empty($record['openid'])}
                    <li>
                        <div class="flexasd" style="display: flex;justify-content: space-around;align-items: center">
                            {if $config['maxcountall']>1 && $record['xunifinish']==0 && $record['isfinish']!=1}
                            <button class="mybtn-con-min" type="button" style="background-color: #FF9999;" data-id="{$record['id']}" data-op="xunifinish">虚拟成团</button>
                            {/if}
                            {if $config['maxcountall']>1 && $record['xunifinish']==1 && $record['isfinish']!=1}
                            <button class="mybtn-con-min" type="button" style="background-color: #FFCCCC;" data-id="{$record['id']}" data-op="unxunifinish">取消虚拟成团</button>
                            {/if}
                            {if $level == '1' && $record['status']!=3}
                            <a href="/{php echo $this->createappurl('w_orderedit', array('op' => 'refund','themeid'=>$themeid, 'id' => $record['id'], 'mobile' => $record['mobile']));}" onclick="if(!confirm('当客户拍错或退单时可以直接退回原账户，确定退款吗')) return false;" class="mybtn-con-min" style="background-color: #db4343;"> 人工退款 </a>
                            {/if}
                        </div>
                    </li>
                    {/if}
<!--                线下订单可删除-->
                    {if $record['status']==3 && ($level=='1' || $config['isxianxia']==1)}
                    <li>
                        <div class="flexasd" style="display: flex;justify-content: space-around;align-items: center">
                            <button id="deleteOffline" class="btn" type="button" style="background-color: #FF9999;" data-id="{$record['id']}" data-op="delete">删除订单</button>
                        </div>
                    </li>
                    {/if}
                {/if}
                    {if $config['is_view_edit_log']==1}
                    <li>
                        <p>修改日志</p>
                        <textarea rows="6"  style="width: 100%;" readonly="readonly">{$record['beizhu']}</textarea>
                    </li>
                    {/if}
                </ul>
            </div>
        </form>
        {include file='fcworker/fc_foot_yixuan'}
        <div class="h110"></div>
        {/if}
        <input type="hidden" name="id" id="param_id" value="{$id}">
        {include file='fcworker/fc_foot'}
    </div>
</div>
</body>
<script>
    const mescroll = new MeScroll("mescroll", {
        down: {
            auto: false,
            callback: () => {
                mescroll.endSuccess();
                setTimeout(() => {
                    window.location.reload();
                },500)
            }
        },
        up: {
            use: false
        }
    })
    function addText(txt){
        var obj = document.getElementById('member_beizhu');
        obj.value = obj.value + txt;
    }

    var level = "{php echo $level;}";
    var maxcountall = "{php echo $config['maxcountall'];}";

    var isedit = "{$config['isedit']}";
    var iseditgroup = "{$config['iseditgroup']}";
    var datetime = "{$config['datetime']}";
    var address = "{$config['address']}";
    var formtwo = "{$config['formtwo']}";
    var addinfo = "{$config['addinfo']}";
    var shops = "{$config['shops']}";
    var shopstype = "{$shopstype}";
    //多选分类点击事件
    let shopsmin = "{$config['shopsmin']}"//分类最小选择数
    let shopsmax = "{$config['shopsmax']}"//分类最多选择数
    let shopstitle = "{$config['shops']}"//
    let wait_pay_amount = 0;//多选支付金额
    {if $config['isedit']}
    $(".shops_category_list_item input[name='formduoxuanvalue']").change(function () {
        let c_min = $(this).data("cmin");
        let c_max = $(this).data("cmax");
        let price = $(this).data("price");
        let category = $(this).data("category");
        let is_default = $(this).data("isdefault");
        let is_checked = $(this).prop("checked");
        if (is_default==1){
            //必选禁止取消
            $(this).prop("checked",'checked');
            layer.msg('必选项禁止取消');
            return;
        }
        if (is_checked){
            //判断分类是否合法
            const c =  $(this).parent().parent().find('input:checked');
            //判断最小选择
            if (c_max>0 && c.length>c_max){
                $(this).prop("checked",'');
                let msg = category+'最多选择'+c_max+'项';
                layer.msg(msg);
                return;
            }
        }
        //判断总量是否合法
        const total_check = $(".shops_category_all").find('input:checked');
        if (total_check.length<shopsmin && shopsmin>0){
            let msg = shopstitle+'最少选择'+shopsmin+'项';
            layer.msg(msg);
            return;
        }
        if (total_check.length>shopsmax && shopsmax>0){
            $(this).prop("checked",'');
            let msg = shopstitle+'最多选择'+shopsmax+'项';
            layer.msg(msg);
            return;
        }
    });

    $('.choseBar18 span').click(function(){
        var formradiovalue = $(this).data("value");
        $("#formradiovalue").val(formradiovalue);
        $(this).addClass('on').siblings().removeClass('on');
    })
    // $('.choseBar19 span').click(function(){
    //     var option_order = $(this).data("value");
    //     $("#option_order").val(option_order);
    //     $(this).addClass('on').siblings().removeClass('on');
    // })
    $('.moreChose span').click(function(){
        var formduoxuanvalue = $(this).data("value");
        $("#formduoxuanvalue").val(formduoxuanvalue);
        if($(this).hasClass('on')){
            $(this).removeClass('on')
        }else{
            $(this).addClass('on')
        }
    })
    {/if}

    var clickStatus = false;
    $(".mybtn-con-min").click(function () {
        var id = $(this).data("id");
        var op = $(this).data("op");
        if (!clickStatus && op){
            clickStatus = true;
            var postUrl="/{php echo createMobileUrl('X_orderedit',array('themeid'=>$themeid));}";
            $.ajax({
                url:postUrl,
                dataType:'json',
                method:'post',
                data: {id:id,op:op},
                success:function (e) {
                    let data = e.data;
                    let error = e.error;
                    let msg = e.msg;
                    if (error!=0){
                        layer.msg(msg);
                    }else {
                        layer.msg('操作成功');
                        self.location.reload();
                    }

                },
                fail:function (err) {
                    console.log(err)
                }
            });
        }


    });
    //线下订单删除
    $("#deleteOffline").click(function () {
        var id = $(this).data("id");
        var postUrl="/{php echo createMobileUrl('X_orderedit',array('themeid'=>$themeid));}";
        var jumpUrl="/{php echo createMobileUrl('X_order',array('themeid'=>$themeid));}";
        $.ajax({
            url:postUrl,
            dataType:'json',
            method:'post',
            data: {id:id,op:'delete'},
            success:function (e) {
                let data = e.data;
                let error = e.error;
                let msg = e.msg;
                if (error!=0){
                    layer.msg(msg);
                }else {
                    layer.msg('操作成功');
                    window.location.href =jumpUrl;
                }

            },
            fail:function (err) {
                console.log(err)
            }
        });
    });    

    $("#sub3").click(function () {
        var formData3 = $("#myform3").serializeArray();
        let datalist = {};
        $.each(formData3,function (index,item) {
            datalist[item.name] = item.value;
        });

        datalist['option'] = datalist['shops'];

        if (shopstype==4 || shopstype==8){
            var  obj = document.getElementsByName("formduoxuanvalue");
            var formoptiontip=[];
            for(var i in obj){
                if(obj[i].checked){
                    formoptiontip.push(obj[i].value);
                    if (obj[i].dataset.price && Number(obj[i].dataset.price)>0){
                        wait_pay_amount+=Number(obj[i].dataset.price);
                    }
                }
            }
            if (!datalist['formduoxuanvalue']){
                datalist['option'] = formoptiontip;
            }else{
                let str = '';
                $.each(formoptiontip,function (key,it){
                    if (shopstype==8){
                        str+= it + ",";
                    }else{
                        str+= it + "|";
                    }

                })
                datalist['option'] = str;
            }
            if (wait_pay_amount>0){
                datalist['realfee']  = wait_pay_amount;
            }
        }

        if (level==1){
            datalist['workerid'] = datalist['windex'];
        }
        if (maxcountall>0 && iseditgroup==1){
            datalist['tuanid'] = datalist['tuanindex'];
        }
        var msg = '';
        if (isedit!='0'){
            if (!datalist['username']){
                msg = '请输入'+$('.nametext').html();
                layer.msg(msg);
                return;
            }
            if (!datalist['mobile'] || datalist['mobile'].length!=11 || !(/^1([3-9])\d{9}$/.test(datalist['mobile']))){
                msg = '请正确输入'+$('.mobiletext').html();
                layer.msg(msg);
                return;
            }

            if (datetime && !datalist['datetime']){
                layer.msg('请输入'+ datetime);
                return;
            }
            if (address && !datalist['address']){
                layer.msg('请输入'+ address);
                return;
            }
            if (formtwo && !datalist['formtwo']){
                layer.msg('请输入'+ formtwo);
                return;
            }
            if (addinfo && !datalist['addinfo']){
                layer.msg('请输入'+ addinfo);
                return;
            }
            if (shops && (!datalist['option'] || datalist['option'].length==0)){
                layer.msg('请输入'+ shops);
                return;
            }
        }

        datalist['op'] = 'save';
        datalist['id'] = $("#param_id").val();
        var postUrl="/{php echo createMobileUrl('X_orderedit',array('themeid'=>$themeid));}";
        $.ajax({
            url:postUrl,
            dataType:'json',
            method:'post',
            data: datalist,
            success:function (e) {
                let data = e.data;
                let error = e.error;
                let msg = e.msg;
                if (error){
                    layer.msg(msg);
                    return;
                }else{
                    layer.msg('保存成功');
                    self.location.reload();
                }
            },
            fail:function (err) {
            }
        });
    });


    $(".edittuan").click(function () {
        layer.prompt({title:'请输入团长的姓名或手机号'},function (val,index) {
            layer.close(index);
            var postUrl="/{php echo createMobileUrl('X_orderedit',array('themeid'=>$themeid));}";
            $.ajax({
                url:postUrl,
                dataType:'json',
                method:'post',
                data: {op:'searchtuan',txt:val},
                success:function (e) {
                    let data = e.data;
                    if (data.errcode==0){
                        layer.msg(data.msg);
                        return;
                    }else{
                        var tuanlist = data.tuanlist;
                        if (tuanlist.length>0){
                            var append_html ='<select id="tuanindex1" name="tuanindex" style="font-size: .28rem">';
                            $.each(tuanlist,function (index,item) {
                                if (index==0){
                                    append_html += ' <option value="' + item.value + '" selected="selected">' + item.name + '</option>';
                                }else{
                                    append_html += ' <option value="' + item.value + '" >' + item.name + '</option>';
                                }
                            });
                            append_html += '</select>';
                            $("#tuanindex").remove();
                            $(".edittuan").before(append_html);
                        }
                    }
                },
                fail:function (err) {
                }
            });
        });
    });

    layui.use('laydate',function () {
        var laydate = layui.laydate;
        var start_date_datetime = "{$config['datetimelimit']['start']}"
        var end_date_datetime = "{$config['datetimelimit']['end']}"
        if (start_date_datetime && end_date_datetime){
            laydate.render({
                elem: '#date_datetime'
                ,min: start_date_datetime
                ,max: end_date_datetime
                ,type: 'date'
                ,trigger: 'click'
                ,btns: ['confirm']
                ,done:function (value, date, endDate) {
                    if (value){
                        $("#date_datetime").val(value);
                    }
                }
            });
        }else{
            laydate.render({
                elem: '#date_datetime'
                ,type: 'date'
                ,trigger: 'click'
                ,btns: ['confirm']
                ,done:function (value, date, endDate) {
                    if (value){
                        $("#date_datetime").val(value);
                    }
                }
            });
        }

    });

    layui.use('laydate',function () {
        var laydate = layui.laydate;
        laydate.render({
            elem: '#date_address'
            ,type: 'date'
            ,trigger: 'click'
            ,btns: ['confirm']
            ,done:function (value, date, endDate) {
                if (value){
                    $("#date_address").val(value);
                }
            }
        });
    });

    layui.use('laydate',function () {
        var laydate = layui.laydate;
        var start_date_formtwo = "{$config['formtwolimit']['start']}"
        var end_date_formtwo = "{$config['formtwolimit']['end']}"
        if (start_date_formtwo && end_date_formtwo){
            laydate.render({
                elem: '#date_formtwo'
                ,min: start_date_formtwo
                ,max: end_date_formtwo
                ,type: 'date'
                ,trigger: 'click'
                ,btns: ['confirm']
                ,done:function (value, date, endDate) {
                    if (value){
                        $("#date_formtwo").val(value);
                    }
                }
            });
        }else{
            laydate.render({
                elem: '#date_formtwo'
                ,type: 'date'
                ,trigger: 'click'
                ,btns: ['confirm']
                ,done:function (value, date, endDate) {
                    if (value){
                        $("#date_formtwo").val(value);
                    }
                }
            });
        }
    });
    layui.use('laydate',function () {
        var laydate = layui.laydate;
        laydate.render({
            elem: '#date_addinfo'
            ,type: 'date'
            ,trigger: 'click'
            ,btns: ['confirm']
            ,done:function (value, date, endDate) {
                if (value){
                    $("#date_addinfo").val(value);
                }
            }
        });
    });
    layui.use('laydate',function () {
        var laydate = layui.laydate;
        laydate.render({
            elem: '#date_shops'
            ,type: 'date'
            ,trigger: 'click'
            ,btns: ['confirm']
            ,done:function (value, date, endDate) {
                if (value){
                    $("#date_shops").val(value);
                }
            }
        });
    });
</script>
</html>